#include "vlselectorcontextwidget.h"

VLSelectorContextWidget::VLSelectorContextWidget(QWidget *parent) :
    VLContextWidget(parent)
{
    layout = setupLayout();

    nameLabel = createAndAddLabel(layout, tr("SELECT"));

    xAxis = createCheckBox(layout, tr("X"));
    connect(xAxis, SIGNAL(stateChanged(int)), this, SLOT(setX(int)));
    yAxis = createCheckBox(layout, tr("Y"));
    connect(yAxis, SIGNAL(stateChanged(int)), this, SLOT(setY(int)));
    zAxis = createCheckBox(layout, tr("Z"));
    connect(zAxis, SIGNAL(stateChanged(int)), this, SLOT(setZ(int)));

    QStringList *strings = new QStringList();
    *strings << tr("Edit Add") << tr("Add") << tr("Subtract") << tr("Edit Subtract");
    actions = createAndAddComboBox(layout, strings);
    connect(actions, SIGNAL(currentIndexChanged(int)), this, SLOT(setAction(int)));

    setDefaults();
}

void VLSelectorContextWidget::setDefaults() {
    actions->setCurrentIndex(TOOL_SELECT->getAction());
}

QCheckBox * VLSelectorContextWidget::createCheckBox(QHBoxLayout *tlayout, QString text) {
    QCheckBox *box = new QCheckBox(text);
    layout->addWidget(box);
    return box;

}

void VLSelectorContextWidget::setX(int val) {
    TOOL_SELECT->setAxis(XAXIS, val);
}

void VLSelectorContextWidget::setY(int val) {
    TOOL_SELECT->setAxis(YAXIS, val);
}

void VLSelectorContextWidget::setZ(int val) {
    TOOL_SELECT->setAxis(ZAXIS, val);
}

void VLSelectorContextWidget::setAction(int val) {
    SelectionTool::ACTION a = SelectionTool::ACTION(val);
    TOOL_SELECT->setAction(a);
}
